/**  
 * @Title: Component.java
 * @Description: TODO(描述)
 * @author liuyi
 * @date 2023-03-23 15:23:33 
 */
package com.fsxgt.datagrid.flow.bo;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson2.annotation.JSONField;

import lombok.Data;

/**
 * @ClassName: ComponentBO
 * @Description: TODO(描述)
 * @author liuyi
 * @date 2023-03-23 15:23:33
 */
@Data
public class FlowComponentBO {


	private String componentSeq;//在当前流程里的唯一标识
	private String componentType;//组件类型，如datax
	private String flowInfoId;
	private String id;
	private String px;
	private String py;
	private String name;
	private String enable;
	
	private Object config;
	
	public FlowComponentBO() {
		
	}

	public FlowComponentBO(String componentSeq) {
		this.componentSeq = componentSeq;
	}
	@JSONField(serialize=false)
	private List<FlowComponentBO> nextComponents = new ArrayList<FlowComponentBO>();

	
	//下一个同级节点
	@JSONField(serialize=false)
	private FlowComponentBO nextSameLevelComponent=null;
	@JSONField(serialize=false)
	private List<FlowComponentBO> linkComponents=new ArrayList<FlowComponentBO>();

//	
	public void addNextComponent(FlowComponentBO componentBO) {
		this.nextComponents.add(componentBO);
	}


	
	public boolean equals(Object anObject) {
		FlowComponentBO bo=(FlowComponentBO) anObject;
		if(bo.getComponentSeq().equals(this.getComponentSeq())) {
			return true;
		}else {
			return false;
		}

	}
	
	public List<FlowComponentBO> findChildren() {
		List list=new ArrayList();
		list.addAll(nextComponents);
		for(FlowComponentBO component:nextComponents) {
			List<FlowComponentBO> children=component.findChildren();
	        for(FlowComponentBO bo :  children) {
	        	//防止死循环
	        	if(bo!=this) { 
	        		list.add(bo);
	        	}
	        }
		}
		return list;
	}
	

	
	

}
